<?php
namespace Register\Form;

use Zend\InputFilter\InputFilter;

class RegisterFormFilter extends InputFilter
{

    public function __construct()
    {
        
        $this->add(array(
            'name' => 'PENDINGEVENT',
            'filters' => array(
                array('name' => 'StringTrim'),
            ),
            'validators' => array(
                array(
                    'name' => 'NotEmpty',
                    'options' => array(
                        'messages' => array(
                            \Zend\Validator\NotEmpty::IS_EMPTY => 'Select An Event!'
                        )
                    )
                )
        
            )
        ));
        
        $this->add(array(
            'name' => 'PHONE',
            'filters' => array(
                array('name' => 'StringTrim'),
            ),
            'validators' => array(
                array(
                    'name' => 'NotEmpty',
                    'options' => array(
                        'messages' => array(
                            \Zend\Validator\NotEmpty::IS_EMPTY => 'Empty'
                        )
                    )
                ),
                array(
                    'name'    => 'StringLength',
                    'options' => array(
                        'encoding' => 'UTF-8',
                        'min'      => 9,
                        'max'      => 10,
                        'messages' => array(
                             'stringLengthTooShort' => 'phone number not have 10 characters!', 
                             'stringLengthTooLong' => 'phone number not have 10 characters!'
                        ),
                    ),
                ),
                array(
                    'name' => 'Regex',
                    'options' => array(
                        'pattern' => '/^[0-9]{9,10}$/',
                        'messages' => array(
                            "regexInvalid"=>"Please enter valid phone number!",
                            "regexNotMatch"=>"Please enter valid phone number!",
                            "regexErrorous"=>"Please enter valid phone number!"
                        ),
                    ),
                ),               
                
            )
        ));
        
        
        
        $this->add(array(
            'name' => 'TITLE',
            'filters' => array(
                array('name' => 'StringTrim'),
            ),
            'validators' => array(
                array(
                    'name'    => 'InArray',
                    'options' => array(
                        'haystack' => array(2,3,4,5,6,7,8,9,10),
                        'messages' => array(
                            'notInArray' => 'Please select a title !'
                        ),
                    ),
                )
        
            )
        ));
        
        $this->add(array(
            'name' => 'FIRST_NAME',
            'required' => true,
            'validators' => array(
                array(
                    'name' => 'NotEmpty',
                    'options' => array(
                        'messages' => array(
                            \Zend\Validator\NotEmpty::IS_EMPTY => 'Empty'
                        )
                    )
                )
            )
        ));
        
        $this->add(array(
            'name' => 'MIDDLE_NAME',
            'required' => false,
            'validators' => array(
                array(
                    'name' => 'NotEmpty',
                    'options' => array(
                        'messages' => array(
                            \Zend\Validator\NotEmpty::IS_EMPTY => 'Empty'
                        )
                    )
                )
            )
        ));
        
        $this->add(array(
            'name' => 'LAST_NAME',
            'required' => true,
            'validators' => array(
                array(
                    'name' => 'NotEmpty',
                    'options' => array(
                        'messages' => array(
                            \Zend\Validator\NotEmpty::IS_EMPTY => 'Empty'
                        )
                    )
                )
            )
        ));
        
        $this->add(array(
            'name' => 'ADDRESS',
            'required' => true,
            'validators' => array(
                array(
                    'name' => 'NotEmpty',
                    'options' => array(
                        'messages' => array(
                            \Zend\Validator\NotEmpty::IS_EMPTY => 'Empty'
                        )
                    )
                )
            )
        ));
        
      /* $this->add(array(
            'name' => 'organization',
            'required' => true,
            'validators' => array(
                array(
                    'name' => 'NotEmpty',
                    'options' => array(
                        'messages' => array(
                            \Zend\Validator\NotEmpty::IS_EMPTY => 'Empty'
                        )
                    )
                )
            )
        ));*/
        
    }
}